package com.trkj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.trkj.dao.QianTaiDao;
import com.trkj.entity.QianTaiEntity;
import com.trkj.entity.QianTaiHouseCostEntity;
import com.trkj.entity.QianTaiParkCostEntity;
import com.trkj.entity.UserRoleEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Service
@Slf4j
public class QianTaiServiceImpl implements QianTaiService{
    @Autowired
    private QianTaiDao qianTaiDao;
    //根据房屋id查房屋的信息
    public List<QianTaiEntity> FanWuXinXi(int id){
        return qianTaiDao.FanWuXinXi(id);
    }
    //根据房屋id分页查询房屋费用情况
    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<QianTaiHouseCostEntity> HouseCost(@RequestBody QianTaiHouseCostEntity qianTaiHouseCostEntity , int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<QianTaiHouseCostEntity> List= this.qianTaiDao.HouseCost(qianTaiHouseCostEntity);
        PageInfo<QianTaiHouseCostEntity> pageDto=new PageInfo<>(List);
        log.debug("房屋:{}",pageDto);
        return pageDto;
    }
    //根据车位id分页查询车位费用情况
    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<QianTaiParkCostEntity> ParkCost(@RequestBody QianTaiParkCostEntity qianTaiParkCostEntity, int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<QianTaiParkCostEntity> List= this.qianTaiDao.ParkCost(qianTaiParkCostEntity);
        PageInfo<QianTaiParkCostEntity> pageDto=new PageInfo<>(List);
        log.debug("车位:{}",pageDto);
        return pageDto;
    }
    //根据车辆id分页查询车辆费用情况
    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<QianTaiParkCostEntity> CarCost(@RequestBody QianTaiParkCostEntity qianTaiParkCostEntity, int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<QianTaiParkCostEntity> List= this.qianTaiDao.CarCost(qianTaiParkCostEntity);
        PageInfo<QianTaiParkCostEntity> pageDto=new PageInfo<>(List);
        log.debug("车位:{}",pageDto);
        return pageDto;
    }
    //收款费用
    public int ShouQuanFei(List<Integer> list){
        return qianTaiDao.ShouQuanFei(list);
    }
}
